import cv2

img = cv2.imread('./img/cat.jpg')
# 上下左右分别要填充多少
top_size, bottom_size, left_size, right_size = (50, 50, 50, 50)
# borderType表示以什么样的方式填充
# 复制法, 也就是复制最边缘的像素
replicate = cv2.copyMakeBorder(img, top_size, bottom_size, left_size, right_size, borderType=cv2.BORDER_REPLICATE)
# 反射法, 对昂兴趣的图像中的像素在两边进行复制, 例如: gfedcba|abcdefg|gfedcba
reflect = cv2.copyMakeBorder(img, top_size, bottom_size, left_size, right_size, borderType=cv2.BORDER_REFLECT)
# 反射法, 也就是以最边缘为轴对称, gfedcb|abcdefg|fedcba
reflect101 = cv2.copyMakeBorder(img, top_size, bottom_size, left_size, right_size, borderType=cv2.BORDER_REFLECT_101)
# 外包装法 abcdefg|abcdefg|abcdefg
wrap = cv2.copyMakeBorder(img, top_size, bottom_size, left_size, right_size, borderType=cv2.BORDER_WRAP)
# 常量法, 常数值填充
constant = cv2.copyMakeBorder(img, top_size, bottom_size, left_size, right_size, borderType=cv2.BORDER_CONSTANT, value=0)
